package com.sicheng.lc.周赛.分类.哈西表or计数or滑动窗口or双指针.计数;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/6/25 22:45
 */
public class 将数组划分成相等数对 {
    //https://leetcode.cn/problems/divide-array-into-equal-pairs/
    public boolean divideArray(int[] nums) {
        int[] cnt = new int[501];
        for (int num : nums) {
            cnt[num]++;
        }
        for (int num : cnt) {
            if ((num & 1) == 1) {
                return false;
            }
        }
        return true;
    }


    public static void main(String[] args) {
        将数组划分成相等数对 solution = new 将数组划分成相等数对();
        int[] nums = {
                9, 9, 19, 10, 9, 12, 2, 12, 3, 3, 11, 5, 8, 4,
                13, 6, 2, 11, 9, 19, 11, 15, 9, 17, 15, 12, 5,
                14, 12, 16, 18, 16, 10, 3, 8, 9, 16, 20, 2, 4,
                16, 12, 11, 14, 20, 16, 2, 18, 17, 20, 3, 13, 16,
                17, 1, 1, 11, 20, 20, 4};

        System.out.println(solution.divideArray(nums));
    }
}
